package com.rran.study.chat.common.utils;

import com.rran.study.chat.common.constant.CommonConstant;
import com.rran.study.chat.common.exception.BusinessErrorEnum;
import com.rran.study.chat.common.exception.BusinessException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class FeignResultUtil {

    private Logger logger = LoggerFactory.getLogger(FeignResultUtil.class);

    public void checkResultCode(String errorCode, String message) {
        if (!CommonConstant.SUCCESS_RESULT.equals(errorCode)) {
            BusinessErrorEnum businessErrorEnum = BusinessErrorEnum.getBusinessError(errorCode);
            if (null != businessErrorEnum) {
                throw new BusinessException(businessErrorEnum);
            }
            throw new BusinessException(new BusinessException(errorCode, message));
        }
    }
}
